package com.ease.platform.dispatcher.vo;

import java.io.Serializable;

import com.ease.common.util.Detect;

public class ImplementationDispatcherParam extends Detect implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 5706896754671943243L;

	// public static final String DEFAULT_SERVICE_ENTRY_KEY_SUFFIX = "_";

	public static final String ENTRY_KEY_SEPERATOR = ".";

	private String entryKey;

	private ImplementationDispatcherParam next;

	public ImplementationDispatcherParam() {
	}

	public ImplementationDispatcherParam(String _entryKey) {
		this.setEntryKey(_entryKey);
	}

	public ImplementationDispatcherParam add(String _entryKey) {
		if (null == this.entryKey) {
			this.setEntryKey(_entryKey);
		} else {
			if (null != next) {
				this.next.add(_entryKey);
			} else {
				this.setNext(new ImplementationDispatcherParam(_entryKey));
			}
		}
		return this;
	}

	public ImplementationDispatcherParam add(long _entryKey) {
		return this.add(String.valueOf(_entryKey));
	}

	public String toString() {
		StringBuffer buffer = new StringBuffer();

		ImplementationDispatcherParam temp = this;
		while (null != temp) {
			if (notEmpty(temp.getEntryKey())) {
				buffer.append(temp.getEntryKey());
			}
			if (null != temp.getNext()) {
				buffer.append(".");
			}
			temp = temp.getNext();
		}
		return buffer.toString();
	}

	/**
	 * @return Returns the entryKey.
	 */
	public String getEntryKey() {
		return entryKey;
	}

	/**
	 * @param entryKey
	 *            The entryKey to set.
	 */
	public void setEntryKey(String entryKey) {
		this.entryKey = entryKey;
	}

	/**
	 * @return Returns the next.
	 */
	public ImplementationDispatcherParam getNext() {
		return next;
	}

	/**
	 * @param next
	 *            The next to set.
	 */
	public void setNext(ImplementationDispatcherParam next) {
		this.next = next;
	}

}
